<?php
include_once("../configure/admin.config.inc.php");	//--> admin global var
include_once("db.inc.php");							//--> db global var
include_once("Smarty.class.php");					//--> out template
include_once("Users.php");							//--> User
include_once("UserGroup.php");						//--> User Group
include_once("Operation.php");						//--> Operation
require_once("controlHeader.php");					//--> system control header

$objOperate		= new Operation($sessionImpl->getLanguage(), $uid);		//--> Operation
$objUser 		= new Users($uid);										//--> user
$objUserGroup 	= new UserGroup($sessionImpl->getLanguage(), $uid);		//--> User Group

if(isset($_GET['groupID']))
	$userGroupID = $_GET['groupID'];
else 
	$userGroupID = 0;

$error_message = '';
	
	
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
	$strQuery = $_SERVER["REQUEST_URI"];
	$arrUrlInfo 	= pathinfo($strQuery);
	$selfFileName	= $arrUrlInfo['filename'];
	
	$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).")");
	
	$i = 0; 
	foreach($arrOperateAllInfo as $key => $value){
		$strFileName = $selfFileName."_".$value['name'].".php";

		if(file_exists($strFileName)){
			$arrOperateInfo[$i]['name'] 		= $value['name'];
			$arrOperateInfo[$i]['viewName'] 	= $value['name'];
			
			$i++;
		}
	}
}

$arrUserGroup = $objUserGroup->arrGetGroupList($gid);

if(is_array($arrUserGroup) && count($arrUserGroup) > 0){
	if(empty($userGroupID))
		$userGroupID = key($arrUserGroup);
}

$arrUserList = $objUser->lists($arrOperate, " WHERE groupid=$userGroupID ORDER BY id DESC", $page, DISPLAY_DATA_SIZE, '');
foreach ($arrUserList as $key => $value){
	$arrGroupInfo = $objUserGroup->getFromID($arrOperate, $value['groupid']);
	if($sessionImpl->getLanguage() == "zh-CN"){
		$arrUserList[$key]['gname'] = $arrGroupInfo['namecn'];
	}else
		$arrUserList[$key]['gname'] = $arrGroupInfo['name'];
}



/*----- out html -----*/
$smarty = new Smarty();					//----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir  = CACHE_SYS_DIR;

$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);

$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);

$smarty->assign('arrUserGroup', $arrUserGroup);
$smarty->assign('arrUserList', $arrUserList);
$smarty->assign('groupidS', $userGroupID);

$smarty->assign('PAGE_BAR', $objUser->pagenav);

$smarty->display('listUser.htm');
?>
